<html>
<head>
<title>AdSense PHP Library Documentation</title>
</head>
<body>
<span style="font-size:18pt;">SensAPIlity Programmer's Manual</span><br/><br/>
<span style="font-weight:bold;font-size:16pt">Utilities.php</span>
<br/><br/>
<span style="font-weight:bold;font-size:14pt">arrayToXML($inputArray)</span>
<br/><br/>
Converts an array to an XML snippet. This does not created a valid XML document, as it does not create the top level &lt;?xml&gt; tag. However, if properly structured, the &lt;?xml&gt; tag should be the only addition you need to make. The array is of the the format<br/><br/>
<span style="font-family:Courier">array(x => array("value" =>  valueOfX, "attributes" => array(attributeZ => valueOfAttribute)))</span><br/><br/>
where x is the name of the tag. valueOfX can itself be an array, which holds tags that are children of x. For example:<br/><br/>
<span style="font-family:Courier">array(x => array("value" =>  array(y => 17, xy => "hello"), "attributes" => array(z => "large")))</span><br/><br/>
would be translated to<br/><br/>
<span style="font-family:Courier">&lt;x z="large"&gt;<br/>
&nbsp;&nbsp;&lt;y&gt;17&lt;/y&gt;<br/>
&nbsp;&nbsp;&lt;xy&gt;hello&lt;/xy&gt;<br/>
&lt;/z&gt;</span>
<br/><br/>
For simple elements that have no attributes and no children the format<br/><br/>
<span style="font-family:Courier">array(x => 17, y => "hello")</span><br/><br/>
can be used, which translates to<br/><br/>
<span style="font-family:Courier">&lt;x&gt;17&lt;/x&gt;<br/>&lt;xy&gt;hello&lt;/xy&gt;</span><br/><br/>
Elements can also have the value null, in which case an empty tag will be produced (ie. <span style="font-family:Courier">&lt;x/&gt;</span>). To be null the value in the array must be such that PHP's <span style="font-family:Courier">is_null()</span> function returns true. Null-valued tags may have attributes.<br/><br/>
There is an apparent problem with a parent having multiple children with the same tag name, for example, how do you generate:<br/>
<br/><span style="font-family:Courier">&lt;request&gt;<br/>
&nbsp;&nbsp;&lt;param&gt;78&lt;/param&gt;<br/>
&nbsp;&nbsp;&lt;param&gt;72&lt;/param&gt;<br/>
&lt;/request&gt;</span><br/><br/>Associative arrays in PHP can't have two keys with the same name. To overcome this, you can pad the tag name with leading or trailing spaces. ArrayToXml() will remove these spaces, so to produce the above example you can building the following array:<br/><br/>
<span style="font-family:Courier">array(request => array("value" =>  array('param' => 78, ' param' => 72)))</span><br/><br/>

</body>
</html>